package com.utils.slider
{
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.geom.Point;
	import flash.utils.getTimer;
	import flash.utils.Timer;
	
	/**
	 * 列表滑动器
	 * @author Shines
	 */
	public class ListIceSlider extends EventDispatcher
	{
		//常量
		public static const HORIZONTAL:int = 0;//横向
		public static const VERTICAL:int = 1;//纵向
		private const LEFT:int = 2;//左
		private const RIGHT:int = 3;//右
		private const UP:int = 4;//上
		private const DOWN:int = 5;//下
		private const OUT_TOP:int = 6;//上越界
		private const OUT_BOTTOM:int = 7;//下越界
		private const INSIDE:int = 8;//正常
		private const MOVE_NORMAL:int = 9;//正常移动
		private const MOVE_BACK:int = 10;//回移
		private const COUNT_STAY:int = 11;//停留计时
		
		//构造需传递的参数
		private var _stage:Stage = null;//场景
		private var _clip:* = null;//剪辑
		private var _itemCount:Number = 0;//列表项个数
		private var _slideDirection:int = VERTICAL;//滑动方向
		private var _itemName:String = "item";//列表项名称前缀
		private var _itemNameIndex:int = 0;//列表项名称开始编号，从0开始或从1开始
		
		//可供设置的参数
		private var _dataCount:int = 0;//数据个数
		private var _currentPlace:Number = 0;//当前指针位置
		private var _dataIndex:int = 0;//当前数据项
		private var _easing:Number = 0.92;//缓动系数
		private var _maxSpeed:Number = 50;//最大速度
		private var _minSpeed:Number = 1;//最小速度
		private var _speedAdjustRate:int = 50;//调速比率，调节松开鼠标后的移动速度
		private var _maxStayTime:int = 3;//最大停留时间(计时器执行次数)
		private var _itemLength:Number = 0;//单个列表项长度
		private var _itemSpacing:Number = 0;//两个列表项间的间距
		
		//列表相关
		private var _listLength:Number = 0;//数据列表总长度
		private var _srcClipPoint:Point = new Point(0, 0);//初始剪辑位置
		private var _prevDataIndex:int = -1;//上一个数据的位置
		private var _isUpdate:Boolean = true;//是否更新数据
		
		//触摸板相关
		private var _topPlace:Number = 0;//上边界
		private var _bottomPlace:Number = 0;//下边界
		private var _outFlag:int = INSIDE;//越界标识
		
		//移动相关
		private var _srcPlace:Number = 0;//初始指标位置(鼠标按下时的指针位置)
		private var _moveDirection:int = LEFT;//移动方向
		private var _speed:Number = 0;//速度
		
		//鼠标状态改变相关
		private var _srcMousePoint:Point = new Point(0, 0);//原鼠标坐标
		private var _destMousePoint:Point = new Point(0, 0);//目标鼠标坐标
		private var _dragDistance:Number = 0;//鼠标拖动剪辑的距离
		private var _srcTime:int = 0;//鼠标按下时的计时器时间(计时器执行次数)
		private var _destTime:int = 0;//鼠标弹起时的计时器时间(计时器执行次数)
		private var _dragTime:int = 0;//鼠标拖动剪辑的时间
		private var _stayPlace:Number = 0;//停留位置
		private var _stayTime:int = 0;//停留时间
		private var _isDrag:Boolean = false;//是否拖动
		
		//计时器相关
		private var _timerFlag:int = MOVE_NORMAL;//计时器标记
		private var _timer:Timer = new Timer(20);//计时器
		
		/**
		 * 构造
		 * @param	aStage	场景
		 * @param	clip	剪辑
		 * @param	itemCount	列表项个数
		 * @param	slideDirection	滑动方向
		 * @param	itemName	列表项名称前缀
		 * @param	itemNameIndex	列表项名称开始编号
		 */
		public function ListIceSlider(aStage:Stage, clip:*, itemCount:int, slideDirection:int = VERTICAL, itemName:String = "item", itemNameIndex:int = 0):void
		{
			//初始化场景、剪辑、列表项个数、滑动方向、列表项名称前缀、列表项名称开始编号
			_stage = aStage;
			_clip = clip;
			_itemCount = itemCount;
			_slideDirection = slideDirection;
			_itemName = itemName;
			_itemNameIndex = itemNameIndex;
			
			//判断移动方向，记录单个列表项长度；计算两个列表项间的间距
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向
					//_itemLength = _clip.item0.width;
					_itemLength = _clip[_itemName + _itemNameIndex].width;
					//_itemSpacing = _clip.item1.x - _clip.item0.x - _clip.item0.width;
					_itemSpacing = _clip[_itemName + (_itemNameIndex + 1)].x - _clip[_itemName + _itemNameIndex].x - _clip[_itemName + _itemNameIndex].width;
					break;
				case VERTICAL:
					//垂直方向
					//_itemLength = _clip.item0.height;
					_itemLength = _clip[_itemName + _itemNameIndex].height;
					//_itemSpacing = _clip.item1.y - _clip.item0.y - _clip.item0.height;
					_itemSpacing = _clip[_itemName + (_itemNameIndex + 1)].y - _clip[_itemName + _itemNameIndex].y - _clip[_itemName + _itemNameIndex].height;
					break;
				default:
			}
			//用列表项个数计算列表总长度
			_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			//记录剪辑初始位置，初始化触摸板相关变量
			//_srcClipPoint.x = _clip.item0.x;
			_srcClipPoint.x = _clip[_itemName + _itemNameIndex].x;
			//_srcClipPoint.y = _clip.item0.y;
			_srcClipPoint.y = _clip[_itemName + _itemNameIndex].y;
			
			addEvents();
		}
		
		/**
		 * 重置状态
		 * 标记停止拖动
		 * 清除上一个数据的位置记录
		 */
		public function reset():void
		{
			_isDrag = false;
			_prevDataIndex = -1;
			_timer.reset();
		}
		
		/**
		 * 设置当前指针位置
		 * 检测修正当前位置
		 * 注：不发生滑动事件
		 * @param	value
		 */
		public function setCurrentPlace(value:Number):void
		{
			_currentPlace = value;
			fixCurrentPlace();
		}
		
		/**
		 * 添加事件
		 * 添加剪辑鼠标按下事件
		 * 添加场景鼠标移动事件
		 * 添加场景鼠标弹起事件
		 * 添加计时器计时事件
		 */
		private function addEvents():void
		{
			_clip.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
			_stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
			_stage.addEventListener(MouseEvent.MOUSE_UP, upHandler);
			_timer.addEventListener(TimerEvent.TIMER, timerHandler);
		}
		
		/**
		 * 移除所有事件
		 */
		private function removeEvents():void
		{
			_clip.removeEventListener(MouseEvent.MOUSE_DOWN, downHandler);
			_stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
			_stage.removeEventListener(MouseEvent.MOUSE_UP, upHandler);
			_timer.removeEventListener(TimerEvent.TIMER, timerHandler);
		}
		
		/**
		 * 鼠标按下事件处理
		 * 停止滑动
		 * 标记开始拖动
		 * 初始化滑动状态
		 * @param	e
		 */
		private function downHandler(e:MouseEvent):void
		{
			_timer.reset();
			_isDrag = true;
			initSlide();
		}
		
		/**
		 * 鼠标移动事件处理
		 * 移动剪辑
		 * @param	e
		 */
		private function moveHandler(e:MouseEvent):void
		{
			//若是拖动状态，则可以拖动
			if (_isDrag)
			{
				//记录目标鼠标位置
				_destMousePoint.x = _stage.mouseX;
				_destMousePoint.y = _stage.mouseY;
				//判断移动方向
				switch (_slideDirection)
				{
					case HORIZONTAL:
						//水平方向，记录位置
						_currentPlace = _srcPlace + _destMousePoint.x - _srcMousePoint.x;
						break;
					case VERTICAL:
						//垂直方向，记录位置
						_currentPlace = _srcPlace + _destMousePoint.y - _srcMousePoint.y;
						break;
					default:
				}
				//检测越界，若越界，则减速
				checkOut();
				switch (_outFlag)
				{
					case INSIDE:
						break;
					case OUT_TOP:
						_currentPlace = _topPlace - (_topPlace - _currentPlace) * 0.06;
						break;
					case OUT_BOTTOM:
						_currentPlace = _bottomPlace + (_currentPlace - _bottomPlace) * 0.06;
						break;
					default:
				}
				//移动剪辑
				moveClip();
			}
		}
		
		/**
		 * 鼠标弹起事件处理
		 * 标记停止拖动
		 * 停止停留计时
		 * 开始滑动
		 * @param	e
		 */
		private function upHandler(e:MouseEvent):void
		{
			if (_isDrag)
			{
				_isDrag = false;
				_timer.reset();
				slide();
			}
		}
		
		/**
		 * 滑动计时器计时事件处理
		 * 根据计时器标记执行相应操作
		 * @param	e
		 */
		private function timerHandler(e:TimerEvent):void
		{
			switch(_timerFlag)
			{
				case MOVE_NORMAL:
					//正常移动
					moveNormal();
					break;
				case MOVE_BACK:
					//回移
					moveBack();
					break;
				case COUNT_STAY:
					//统计停留计时
					countStay();
					break;
				default:
			}
		}
		
		/**
		 * 正常移动
		 */
		private function moveNormal():void
		{
			//改变位置，检测越界
			changePlace();
			checkOut();
			//若越界，则速度下降
			if (_outFlag != INSIDE)
			{
				_speed *= 0.4;
			}
			//移动剪辑
			moveClip();
			//若达到最小速度，则停止继续移动，否则减速移动
			if (_speed <= _minSpeed)
			{
				_timer.reset();
				//若出界，则启动回移
				if (_outFlag != INSIDE)
				{
					startBack();
				}
			}
			else
			{
				slowDown();
			}
		}
		
		/**
		 * 回移
		 * 根据越界状态进行回移
		 */
		private function moveBack():void
		{
			switch (_outFlag)
			{
				case INSIDE:
					_timer.reset();
					break;
				case OUT_TOP:
					//上越界，改变位置，若已移到边界，则停止移动
					backPlace();
					if (_currentPlace >= _topPlace)
					{
						_currentPlace = _topPlace;
						_timer.reset();
					}
					//移动剪辑，减速
					moveClip();
					slowDown();
					break;
				case OUT_BOTTOM:
					//下越界，改变位置，若已移到边界，则停止移动
					backPlace();
					if (_currentPlace <= _bottomPlace)
					{
						_currentPlace = _bottomPlace;
						_timer.reset();
					}
					//移动剪辑，减速
					moveClip();
					slowDown();
					break;
				default:
			}
		}
		
		/**
		 * 统计停留时间
		 * 根据移动方向，累计停留时间
		 */
		private function countStay():void
		{
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向，若初始位置和剪辑位置为同一位置，则记录停留时间，否则，将初始位置设为剪辑位置
					if (_stayPlace == _stage.mouseX)
					{
						_stayTime++;
					}
					else
					{
						_stayPlace = _stage.mouseX;
					}
					break;
				case VERTICAL:
					//垂直方向，若初始位置和剪辑位置为同一位置，则记录停留时间，否则，将初始位置设为剪辑位置
					if (_stayPlace == _stage.mouseY)
					{
						_stayTime++;
					}
					else
					{
						_stayPlace = _stage.mouseY;
					}
					break;
				default:
			}
		}
		
		/**
		 * 改变位置
		 */
		private function changePlace():void
		{
			switch (_moveDirection)
			{
				case LEFT:
					_currentPlace -= _speed;
					break;
				case RIGHT:
					_currentPlace += _speed;
					break;
				case UP:
					_currentPlace -= _speed;
					break;
				case DOWN:
					_currentPlace += _speed;
					break;
				default:
			}
		}
		
		/**
		 * 检测越界
		 */
		private function checkOut():void
		{
			if (_currentPlace < _topPlace)
			{
				_outFlag = OUT_TOP;
			}
			else if (_currentPlace > _bottomPlace)
			{
				_outFlag = OUT_BOTTOM;
			}
			else
			{
				_outFlag = INSIDE;
			}
		}
		
		/**
		 * 移动剪辑
		 */
		private function moveClip():void
		{
			var offset:Number = 0;//偏移量
			var i:int = 0;//循环变量
			
			switch (_outFlag)
			{
				case INSIDE:
					//未越界，设置偏移量、数据位置
					//offset = _currentPlace % (_itemLength + _itemSpacing);
					offset = _currentPlace - int(_currentPlace / (_itemLength + _itemSpacing)) * (_itemLength + _itemSpacing);
					_dataIndex = int( -_currentPlace / (_itemLength + _itemSpacing));
					break;
				case OUT_TOP:
					//上越界，设置偏移量、数据位置，若数据位置大于列表项位置，则数据位置为数据个数减去列表项个数的值
					offset = _currentPlace - _topPlace;
					if (_dataCount > _itemCount)
					{
						_dataIndex = _dataCount - _itemCount;
					}
					else
					{
						_dataIndex = 0;
					}
					break;
				case OUT_BOTTOM:
					//下越界，设置偏移量、数据位置
					offset = _currentPlace - _bottomPlace;
					_dataIndex = 0;
					break;
				default:
			}
			
			//若当前数据位置不是上一个数据位置，则标记刷新数据，否则标记不刷新数据
			if (_dataIndex != _prevDataIndex)
			{
				_isUpdate = true;
				_prevDataIndex = _dataIndex;
			}
			else
			{
				_isUpdate = false;
			}
			//发生滑动事件
			dispatchEvent(new Event(Event.CHANGE));
			
			//判断移动方向，移动剪辑
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向
					for (i = 0; i <= _itemCount; i++)
					{
						//_clip["item" + i].x = _srcClipPoint.x + offset + i * (_itemLength + _itemSpacing);
						_clip[_itemName + (_itemNameIndex + i)].x = _srcClipPoint.x + offset + i * (_itemLength + _itemSpacing);
					}
					break;
				case VERTICAL:
					//垂直方向
					for (i = 0; i <= _itemCount; i++)
					{
						//_clip["item" + i].y = _srcClipPoint.y + offset + i * (_itemLength + _itemSpacing);
						_clip[_itemName + (_itemNameIndex + i)].y = _srcClipPoint.y + offset + i * (_itemLength + _itemSpacing);
					}
					break;
				default:
			}
			//若数据个数少于列表项个数，或当前位置已出边界，则隐藏用于滚动的最后那个列表项
			if (_dataCount <= _itemCount || _outFlag != INSIDE)
			{
				//_clip["item" + _itemCount].visible = false;
				_clip[_itemName + (_itemNameIndex + _itemCount)].visible = false;
			}
			else
			{
				//_clip["item" + _itemCount].visible = true;
				_clip[_itemName + (_itemNameIndex + _itemCount)].visible = true;
			}
		}
		
		/**
		 * 启动回移
		 * 根据滑动方向和越界标识，设置回移速度，标记移动方向
		 */
		private function startBack():void
		{
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向，设置回移速度，标记移动方向
					switch (_outFlag)
					{
						case INSIDE:
							break;
						case OUT_TOP:
							_speed = (_topPlace - _currentPlace) / 8;
							_moveDirection = LEFT;
							break;
						case OUT_BOTTOM:
							_speed = (_currentPlace - _bottomPlace) / 8;
							_moveDirection = RIGHT;
							break;
						default:
					}
					break;
				case VERTICAL:
					//垂直方向，设置回移速度，标记移动方向
					switch (_outFlag)
					{
						case INSIDE:
							break;
						case OUT_TOP:
							_speed = (_topPlace - _currentPlace) / 8;
							_moveDirection = UP;
							break;
						case OUT_BOTTOM:
							_speed = (_currentPlace - _bottomPlace) / 8;
							_moveDirection = DOWN;
							break;
						default:
					}
					break;
				default:
			}
			//启动回移
			_timerFlag = MOVE_BACK;
			_timer.start();
		}
		
		/**
		 * 减速
		 */
		private function slowDown():void
		{
			if (_speed * _easing > _minSpeed)
			{
				_speed *= _easing;
			}
			else
			{
				_speed = _minSpeed;
			}
		}
		
		/**
		 * 回移改变位置
		 * 根据移动方向，改变位置
		 */
		private function backPlace():void
		{
			switch (_moveDirection)
			{
				case LEFT:
					_currentPlace += _speed;
					break;
				case RIGHT:
					_currentPlace -= _speed;
					break;
				case UP:
					_currentPlace += _speed;
					break;
				case DOWN:
					_currentPlace -= _speed;
					break;
				default:
			}
		}
		
		/**
		 * 初始化滑动状态
		 */
		private function initSlide():void
		{
			//记录移动时鼠标初始坐标
			_srcMousePoint.x = _stage.mouseX;
			_srcMousePoint.y = _stage.mouseY;
			//记录移动初始时间、设置初始指标位置
			_srcTime = getTimer();
			_srcPlace = _currentPlace;
			//开始累计停留时间
			startStayTime();
		}
		
		/**
		 * 开始累计停留时间
		 */
		private function startStayTime():void
		{
			_stayPlace = _stage.mouseX;
			_stayTime = 0;
			_timerFlag = COUNT_STAY;
			_timer.start();
		}
		
		/**
		 * 滑动
		 */
		private function slide():void
		{
			//记录鼠标移动终点坐标，记录移动终点时间
			_destMousePoint.x = _stage.mouseX;
			_destMousePoint.y = _stage.mouseY;
			_destTime = getTimer();
			//计算拖动时间
			_dragTime = (_destTime - _srcTime);
			if (_dragTime <= 0)
			{
				_dragTime = 1;
			}
			
			//根据移动方向，计算速度
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向，计算拖动距离，计算速度
					_dragDistance = _destMousePoint.x - _srcMousePoint.x;
					_speed = _dragDistance / _dragTime * _speedAdjustRate;
					//标记移动方向，速度小于0时，为左，速度转为正数；速度大于0时，为右
					if (_speed < 0)
					{
						_moveDirection = LEFT;
						_speed = -_speed;
					}
					else if (_speed > 0)
					{
						_moveDirection = RIGHT;
					}
					break;
				case VERTICAL:
					//垂直方向，计算拖动距离，计算速度
					_dragDistance = _destMousePoint.y - _srcMousePoint.y;
					_speed = _dragDistance / _dragTime * _speedAdjustRate;
					//标记移动方向，速度小于0时，为上，速度转为正数；速度大于0时，为下
					if (_speed < 0)
					{
						_moveDirection = UP;
						_speed = -_speed;
					}
					else if (_speed > 0)
					{
						_moveDirection = DOWN;
					}
					break;
				default:
			}
			
			//检测越界
			checkOut();
			//若越界，则启动回移
			if (_outFlag != INSIDE)
			{
				startBack();
			}
			else
			{
				//若停留时间小于最大停留时间，且速度不为0，则检测调整速度，开始滑动，否则不滑动
				if (_stayTime < _maxStayTime && _speed != 0)
				{
					fixSpeed();
					_timerFlag = MOVE_NORMAL;
					_timer.start();
				}
			}
		}
		
		/**
		 * 修正速度
		 * 使速度在指定的范围之内
		 */
		private function fixSpeed():void
		{
			if (_speed < _minSpeed)
			{
				_speed = _minSpeed;
			}
			else if (_speed > _maxSpeed)
			{
				_speed = _maxSpeed;
			}
		}
		
		/**
		 * 修正当前位置
		 * 使当前位置在有效范围之内
		 */
		private function fixCurrentPlace():void
		{
			if (_currentPlace < _topPlace)
			{
				_currentPlace = _topPlace;
			}
			else if (_currentPlace > _bottomPlace)
			{
				_currentPlace = _bottomPlace;
			}
		}
		
		/**
		 * 同步位置更新
		 */
		private function refreshPlace():void
		{
			//修正当前位置，清除上一个数据的位置记录，检测越界，移动剪辑
			fixCurrentPlace();
			_prevDataIndex = -1;
			checkOut();
			moveClip();
		}
		
		/*========================== Getter and setter =========================*/
		
		/**
		 * 获取、设置列表项个数
		 */
		public function get itemCount():Number { return _itemCount; }
		public function set itemCount(value:Number):void
		{
			//设置列表项
			_itemCount = value;
			//若数据个数大于列表项个数，则将用数据个数来计算列表总长度，否则用列表项个数计算列表总长度
			if (_dataCount > _itemCount)
			{
				_listLength = _dataCount * _itemLength + (_dataCount - 1) * _itemSpacing;
			}
			else
			{
				_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			}
			//设置上边界，同步位置更新
			_topPlace = -(_listLength - (_itemCount * _itemLength + (_itemCount - 1) * _itemSpacing));
			refreshPlace();
		}
		
		/**
		 * 获取、设置滑动方向
		 */
		public function get slideDirection():int { return _slideDirection; }
		public function set slideDirection(value:int):void
		{
			_slideDirection = value;
			
			//判断移动方向，记录单个列表项长度；计算两个列表项间的间距
			switch (_slideDirection)
			{
				case HORIZONTAL:
					//水平方向
					//_itemLength = _clip.item0.width;
					_itemLength = _clip[_itemName + _itemNameIndex].width;
					//_itemSpacing = _clip.item1.x - _clip.item0.x - _clip.item0.width;
					_itemSpacing = _clip[_itemName + (_itemNameIndex + 1)].x - _clip[_itemName + _itemNameIndex].x - _clip[_itemName + _itemNameIndex].width;
					break;
				case VERTICAL:
					//垂直方向
					//_itemLength = _clip.item0.height;
					_itemLength = _clip[_itemName + _itemNameIndex].height;
					//_itemSpacing = _clip.item1.y - _clip.item0.y - _clip.item0.height;
					_itemSpacing = _clip[_itemName + (_itemNameIndex + 1)].y - _clip[_itemName + _itemNameIndex].y - _clip[_itemName + _itemNameIndex].height;
					break;
				default:
			}
			//用列表项个数计算列表总长度
			_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			//记录剪辑初始位置，初始化触摸板相关变量
			//_srcClipPoint.x = _clip.item0.x;
			_srcClipPoint.x = _clip[_itemName + _itemNameIndex].x;
			//_srcClipPoint.y = _clip.item0.y;
			_srcClipPoint.y = _clip[_itemName + _itemNameIndex].y;
		}
		
		/**
		 * 获取、设置数据个数
		 */
		public function get dataCount():int { return _dataCount; }
		public function set dataCount(value:int):void
		{
			//设置数据个数
			_dataCount = value;
			//若数据个数大于列表项个数，则将用数据个数来计算列表总长度，否则用列表项个数计算列表总长度
			if (_dataCount > _itemCount)
			{
				_listLength = _dataCount * _itemLength + (_dataCount - 1) * _itemSpacing;
			}
			else
			{
				_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			}
			//设置上边界，同步位置更新
			_topPlace = -(_listLength - (_itemCount * _itemLength + (_itemCount - 1) * _itemSpacing));
			refreshPlace();
		}
		
		/**
		 * 获取、设置当前位置
		 */
		public function get currentPlace():Number { return _currentPlace; }
		public function set currentPlace(value:Number):void
		{
			//设置当前指针位置，同步位置更新
			_currentPlace = value;
			refreshPlace();
		}
		
		/**
		 * 获取、设置当前数据项
		 */
		public function get dataIndex():int { return _dataIndex; }
		public function set dataIndex(value:int):void
		{
			//设置当前数据位置、当前指针位置，同步位置更新
			_dataIndex = value;
			_currentPlace = _bottomPlace - _dataIndex * (_itemLength + _itemSpacing);
			refreshPlace();
		}
		
		/**
		 * 获取、设置缓动系数
		 */
		public function get easing():Number { return _easing; }
		public function set easing(value:Number):void
		{
			_easing = value;
		}
		
		/**
		 * 获取、设置最大速度
		 */
		public function get maxSpeed():Number { return _maxSpeed; }
		public function set maxSpeed(value:Number):void
		{
			_maxSpeed = value;
		}
		
		/**
		 * 获取、设置最小速度
		 */
		public function get minSpeed():Number { return _minSpeed; }
		public function set minSpeed(value:Number):void
		{
			_minSpeed = value;
		}
		
		/**
		 * 获取、设置调速比率
		 */
		public function get speedAdjustRate():int { return _speedAdjustRate; }
		public function set speedAdjustRate(value:int):void
		{
			_speedAdjustRate = value;
		}
		
		/**
		 * 获取、设置最大停留时间
		 */
		public function get maxStayTime():int { return _maxStayTime; }
		public function set maxStayTime(value:int):void
		{
			_maxStayTime = value;
		}
		
		/**
		 * 获取、设置单个列表项长度
		 */
		public function get itemLength():Number { return _itemLength; }
		public function set itemLength(value:Number):void
		{
			_itemLength = value;
			//若数据个数大于列表项个数，则将用数据个数来计算列表总长度，否则用列表项个数计算列表总长度
			if (_dataCount > _itemCount)
			{
				_listLength = _dataCount * _itemLength + (_dataCount - 1) * _itemSpacing;
			}
			else
			{
				_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			}
			//设置上边界，同步位置更新
			_topPlace = -(_listLength - (_itemCount * _itemLength + (_itemCount - 1) * _itemSpacing));
			refreshPlace();
		}
		
		/**
		 * 获取、设置两个列表项间的间距
		 */
		public function get itemSpacing():Number { return _itemSpacing; }
		public function set itemSpacing(value:Number):void
		{
			//设置两个列表项间的间距
			_itemSpacing = value;
			//若数据个数大于列表项个数，则将用数据个数来计算列表总长度，否则用列表项个数计算列表总长度
			if (_dataCount > _itemCount)
			{
				_listLength = _dataCount * _itemLength + (_dataCount - 1) * _itemSpacing;
			}
			else
			{
				_listLength = _itemCount * _itemLength + (_itemCount - 1) * _itemSpacing;
			}
			//设置上边界，同步位置更新
			_topPlace = -(_listLength - (_itemCount * _itemLength + (_itemCount - 1) * _itemSpacing));
			refreshPlace();
		}
		
		/**
		 * 获取剪辑
		 */
		public function get clip():* { return _clip; }
		
		/**
		 * 获取是否更新数据
		 */
		public function get isUpdate():Boolean { return _isUpdate; }
		
		/**
		 * 获取上边界
		 */
		public function get topPlace():Number { return _topPlace; }
		
		/**
		 * 获取下边界
		 */
		public function get bottomPlace():Number { return _bottomPlace; }
	}
}
